<template>
  <div class="global_order marginTop10">
    <div class="main_white padding10 paddingTop0">
      <div class="main_ti">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="全局配置" name="0"></el-tab-pane>
          <el-tab-pane label="订单配置" name="1"></el-tab-pane>
          <el-tab-pane label="商品配置" name="2"></el-tab-pane>
          <el-tab-pane label="库房配置" name="3"></el-tab-pane>
          <el-tab-pane label="商户配置" name="4"></el-tab-pane>
          <el-tab-pane label="采购配置" name="5"></el-tab-pane>
        </el-tabs>

        <div class="mainua_form marginTop20">
          <el-form
            :model="overall_form"
            :inline="false"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="180px"
            v-if="activeName == 0"
          >
            <el-form-item class="flex_center" prop="show_member_code">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                   显示商户编码
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >显示商户编码：
              </span>
              <el-switch
                v-model="overall_form.show_member_code"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="order_number_generation_rule ">
              <span slot="label">
               单据号生成规则：
              </span>
              <el-checkbox-group v-model="overall_form.order_number_generation_rule">
                <el-checkbox
                  :label="0"
                  class="marginRight0"
                  @change="checkboxGroup(0,1)"
                  >顺序生成</el-checkbox
                >
                <el-checkbox
                  :label="1"
                  class="marginLeft20 marginRight0"
                  @change="checkboxGroup(1,1)"
                  >随机生成</el-checkbox
                >
              </el-checkbox-group>
            </el-form-item>
            <div class="clearfix"></div>
            <div class="newConBox_p100 paddingBottom10" id="newConBox">
              <div class="newConBox_h32">
                <div
                  :class="[
                    'mainua_an newConBox ',
                    { on: searchBarFixed },
                    { marginLeft5: !searchBarFixed },
                  ]"
                >
                  <el-button type="primary" @click="preservation" v-repeatClick
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
          </el-form>
          <el-form
            :model="order_form"
            :inline="false"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="180px"
            v-if="activeName == 1"
          >
            <el-form-item class="flex_center" prop="check_designated_inventory">
              <span slot="label"> 后台下单验证指定库存： </span>
              <el-switch
                v-model="order_form.check_designated_inventory"
                active-text="开"
                inactive-text="关"
                class="mainor_switch"
                active-color="#03A98E"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="createTime">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                   移动端每天开始下单与结束下单时间段！
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >允许下单时间段：
              </span>
              <el-time-picker
                is-range
                v-model="createTime"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                placeholder="选择时间范围"
                value-format="HH:mm:ss"
                format="HH:mm:ss"
                >
              </el-time-picker>
            </el-form-item>
            <el-form-item class="flex_center" prop="allow_add_sold_out">
              <span slot="label"> 后台允许添加下架商品： </span>
              <el-switch
                v-model="order_form.allow_add_sold_out"
                active-text="开"
                inactive-text="关"
                class="mainor_switch"
                active-color="#03A98E"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="use_recent_remark">
              <span slot="label"> 商品自动调用近一次备注： </span>
              <el-switch
                v-model="order_form.use_recent_remark"
                active-text="开"
                inactive-text="关"
                class="mainor_switch"
                active-color="#03A98E"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="order_goods_sort">
              <span slot="label"> 订单商品排序： </span>
              <el-checkbox-group v-model="order_form.order_goods_sort">
                <el-checkbox
                  :label="0"
                  class="marginRight0"
                  @change="checkboxGroup(0,2)"
                  >商品添加顺序</el-checkbox
                >
                <el-checkbox
                  :label="1"
                  class="marginLeft20 marginRight0"
                  @change="checkboxGroup(1,2)"
                  >按分类排序</el-checkbox
                >
              </el-checkbox-group>
            </el-form-item>
            <el-form-item class="flex_center" prop="order_audit">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                    开启后，商户自主提交的货到付款订单需平台审核
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >订单审核：
              </span>
              <el-switch
                v-model="order_form.order_audit"
                active-text="开"
                inactive-text="关"
                class="mainor_switch"
                active-color="#03A98E"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="return_audit">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">开启后，后台创建的退货单也需要审核</div>
                  <i class="el-icon-question"></i> </el-tooltip
                >退货单审核：
              </span>
              <el-switch
                v-model="order_form.return_audit"
                active-text="开"
                inactive-text="关"
                class="mainor_switch"
                active-color="#03A98E"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="new_order_voice_switch">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                    开启后，客户端商户自主提交的订单，后台有语音提醒，系统提供可选语音
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >新订单语音提醒：
              </span>
              <el-switch
                v-model="order_form.new_order_voice_switch"
                active-text="开"
                inactive-text="关"
                class="mainor_switch"
                active-color="#03A98E"
              ></el-switch>
            </el-form-item>
            <el-form-item
              class="flex_center"
              label=" "
              label-width="80px"
              prop="use_yuyi"
              v-if="order_form.new_order_voice_switch"
            >
              <el-checkbox-group v-model="order_form.new_order_voice_alert">
                <el-checkbox
                  v-for="(yuyi,index) in yuyi"
                  :key="index"
                  :label="yuyi.url"
                  :class="[{marginLeft20:index!=0},' marginRight0']"
                  @change="checkboxGroup(yuyi.url,3)"
                  >{{ yuyi.name }}</el-checkbox
                >
              </el-checkbox-group>
            </el-form-item>
            <div class="clearfix"></div>
            <div class="newConBox_p100 paddingBottom10" id="newConBox">
              <div class="newConBox_h32">
                <div
                  :class="[
                    'mainua_an newConBox ',
                    { on: searchBarFixed },
                    { marginLeft5: !searchBarFixed },
                  ]"
                >
                  <el-button type="primary" @click="preservation" v-repeatClick
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
          </el-form>
          <el-form
            :model="commodity_form"
            :inline="false"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="180px"
            v-if="activeName == 2"
          >
            <el-form-item class="flex_center" prop="show_sku_code">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                    开启后，创建订单添加商品等，执行检索商品，结果中SKU编码会显示在名称下方
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >显示SKU编码：
              </span>
              <el-switch
                v-model="commodity_form.show_sku_code"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <div class="clearfix"></div>
            <div class="newConBox_p100 paddingBottom10" id="newConBox">
              <div class="newConBox_h32">
                <div
                  :class="[
                    'mainua_an newConBox ',
                    { on: searchBarFixed },
                    { marginLeft5: !searchBarFixed },
                  ]"
                >
                  <el-button type="primary" @click="preservation" v-repeatClick
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
          </el-form>
          <el-form
            :model="warehouse_form"
            :inline="false"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="180px"
            v-if="activeName == 3"
          >
            <el-form-item class="flex_center" prop="storage_audit">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">开启后，所有入库必须审核</div>
                  <i class="el-icon-question"></i> </el-tooltip
                >审核入库：
              </span>
              <el-switch
                v-model="warehouse_form.storage_audit"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="loss_stock">
              <span slot="label">
                发货出库允许负库存：
              </span>
              <el-switch
                v-model="warehouse_form.loss_stock"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="inventory_sheet_audit">
              <span slot="label">
                盘点单需审核：
              </span>
              <el-switch
                v-model="warehouse_form.inventory_sheet_audit"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="reported_spills_autdit">
              <span slot="label">
                库存调整需审核：
              </span>
              <el-switch
                v-model="warehouse_form.reported_spills_autdit"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <div class="clearfix"></div>
            <div class="newConBox_p100 paddingBottom10" id="newConBox">
              <div class="newConBox_h32">
                <div
                  :class="[
                    'mainua_an newConBox ',
                    { on: searchBarFixed },
                    { marginLeft5: !searchBarFixed },
                  ]"
                >
                  <el-button type="primary" @click="preservation" v-repeatClick
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
          </el-form>
          <el-form
            :model="user_form"
            :inline="false"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="180px"
            v-if="activeName == 4"
          >
            <el-form-item class="flex_center" prop="register_audit">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">默认为手动，开启为自动</div>
                  <i class="el-icon-question"></i> </el-tooltip
                >注册审核方式：
              </span>
              <el-switch
                v-model="user_form.register_audit"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="register_pay_type">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">默认为货到付款，开启为前支付</div>
                  <i class="el-icon-question"></i> </el-tooltip
                >注册支付方式：
              </span>
              <el-switch
                v-model="user_form.register_pay_type"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="credit_status">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                    开启后，提交订单（含后台）时当欠款达到预设额度，将警告或不能下单
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >信用金：
              </span>
              <el-switch
                v-model="user_form.credit_status"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <div v-if="user_form.credit_status">
              <el-form-item prop="credit">
                <span slot="label">
                  <el-tooltip
                    class="item marginRight5 mainor_tei"
                    effect="dark"
                    placement="top"
                  >
                    <div slot="content">
                      新商户注册（含后台创建、导入）默认信用金额度
                    </div>
                    <i class="el-icon-question"></i> </el-tooltip
                  >信用金默认额度：
                </span>

                <el-input
                  placeholder="请输入默认信用金"
                  v-model="user_form.credit"
                  class="wid400"
                ></el-input
                >&nbsp;元
              </el-form-item>
              <el-form-item prop="credit_notice">
                <span slot="label">
                  <el-tooltip
                    class="item marginRight5 mainor_tei"
                    effect="dark"
                    placement="top"
                  >
                    <div slot="content">
                      当商户欠款额度达到提醒预设比例后，每次下单都会提醒信用金使用情况
                    </div>
                    <i class="el-icon-question"></i> </el-tooltip
                  >超额提醒：
                </span>
                <el-input
                  placeholder="信用金提醒额度"
                  v-model="user_form.credit_notice"
                  class="wid400"
                ></el-input>
                <span>&nbsp;%</span>
              </el-form-item>
              <el-form-item prop="forbid_order">
                <span slot="label">
                  <el-tooltip
                    class="item marginRight5 mainor_tei"
                    effect="dark"
                    placement="top"
                  >
                    <div slot="content">
                      当商户欠款额度达到停止下单预设比例后，不能下单
                    </div>
                    <i class="el-icon-question"></i> </el-tooltip
                  >停止下单：
                </span>
                <el-input
                  placeholder="信用金关闭额度"
                  v-model="user_form.forbid_order"
                  class="wid400"
                ></el-input>
                <span>&nbsp;%</span>
              </el-form-item>
            </div>
            <div class="clearfix"></div>
            <div class="newConBox_p100 paddingBottom10" id="newConBox">
              <div class="newConBox_h32">
                <div
                  :class="[
                    'mainua_an newConBox ',
                    { on: searchBarFixed },
                    { marginLeft5: !searchBarFixed },
                  ]"
                >
                  <el-button type="primary" @click="preservation" v-repeatClick
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
          </el-form>
          <el-form
            :model="purchasing_form"
            :inline="false"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="220px"
            v-if="activeName == 5"
          >
            <el-form-item class="flex_center" prop="purchase_allow_add_sold_out">
              <span slot="label">
                <el-tooltip
                  class="item marginRight5 mainor_tei"
                  effect="dark"
                  placement="top"
                >
                  <div slot="content">
                    备货采购允许添加下架商品 开启后，创建备货采购时可以添加下架的商品
                  </div>
                  <i class="el-icon-question"></i> </el-tooltip
                >备货采购允许添加下架商品：
              </span>
              <el-switch
                v-model="purchasing_form.purchase_allow_add_sold_out"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="purchase_goods_sort">
              <span slot="label">
                采购单商品排序：
              </span>
              <el-checkbox-group v-model="purchasing_form.purchase_goods_sort">
                <el-checkbox
                  :label="0"
                  class="marginRight0"
                  @change="checkboxGroup(0,4)"
                  >按分类排序</el-checkbox
                >
                <el-checkbox
                  :label="1"
                  class="marginLeft20 marginRight0"
                  @change="checkboxGroup(1,4)"
                  >商品添加排序</el-checkbox
                >
              </el-checkbox-group>
            </el-form-item>
            <el-form-item class="flex_center" prop="purchase_return_audit">
              <span slot="label">
                采购退货需审核：
              </span>
              <el-switch
                v-model="purchasing_form.purchase_return_audit"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <el-form-item class="flex_center" prop="purchase_return_check_inventory">
              <span slot="label">
                采购退货需库存满足：
              </span>
              <el-switch
                v-model="purchasing_form.purchase_return_check_inventory"
                active-text="开"
                inactive-text="关"
                active-color="#03A98E"
                class="mainor_switch"
              ></el-switch>
            </el-form-item>
            <div class="clearfix"></div>
            <div class="newConBox_p100 paddingBottom10" id="newConBox">
              <div class="newConBox_h32">
                <div
                  :class="[
                    'mainua_an newConBox ',
                    { on: searchBarFixed },
                    { marginLeft5: !searchBarFixed },
                  ]"
                >
                  <el-button type="primary" @click="preservation" v-repeatClick
                    >保存</el-button
                  >
                </div>
              </div>
            </div>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { setting_info } from "@/api/global/globalSystem";
import { setting_company } from "@/api/currency";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";

export default {
  computed: {
    ...mapGetters(["avatar"]),
  },
  data() {
    return {
      // 搜索
      overall_form: {
        show_member_code : true,
        order_number_generation_rule : [0],
      },
      order_form: {
        order_audit: true,
        open_time: "",
        end_time: "",
        check_designated_inventory: true,
        allow_add_sold_out: false,
        use_recent_remark: true,
        order_goods_sort: [0],
        return_audit: true,
        new_order_voice_alert: ['/voice/myrecord.wav'],
        new_order_voice_switch: true,
      },
      createTime: ['00:00:00','00:00:00'],
      yuyi:[
        {
          name:'音乐1',
          url:'/voice/myrecord.wav',
        },
        {
          name:'音乐2',
          url:'/voice/ring_tone_one.mp3'
        },
        {
          name:'音乐3',
          url:'/voice/ring_tone_two.mp3'
        },
        {
          name:'音乐4',
          url:'/voice/ring_tone_three.mp3'
        },
        {
          name:'音乐5',
          url:'/voice/ring_tone_four.mp3'
        }
      ],
      commodity_form: {
        show_sku_code: false,
      },
      warehouse_form: {
        storage_audit: false,
        loss_stock: true,
        inventory_sheet_audit: true,
        reported_spills_autdit: true,
      },
      user_form: {
        register_audit: false,
        register_pay_type: false,
        credit_status: false,
        credit: "",
        credit_notice: "",
        forbid_order: "",
      },
      purchasing_form: {
        purchase_goods_sort: [0],
        purchase_return_audit: true,
        purchase_return_check_inventory: true,
        purchase_allow_add_sold_out: true,
      },
      // 菜单切换
      activeName: "0",
      // 监听滚动
      searchBarFixed: false,
    };
  },
  mounted() {
    window.addEventListener("scroll", this.handleScroll);
  },
  destroyed() {
    window.removeEventListener("scroll", this.handleScroll);
  },
  methods: {
    // 监听滚动
    handleScroll() {
      let scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      scrollTop + document.documentElement.clientHeight >
      document.getElementById("newConBox").offsetTop + 300
        ? (this.searchBarFixed = false)
        : (this.searchBarFixed = true);
    },
    // 选中菜单
    handleClick(tab, event) {
      this.searchBarFixed = false;
      if (this.$refs["userListFrom"]) {
        this.$refs["userListFrom"].clearValidate();
      }
    },
    // 单选
    checkboxGroup(val,type) {
      if(type==3){
        this.order_form.new_order_voice_alert=[]
        this.order_form.new_order_voice_alert.push(val)
      }else if(type==2){
        this.order_form.order_goods_sort=[]
        this.order_form.order_goods_sort.push(val)
      }else if(type==1){
        this.overall_form.order_number_generation_rule =[]
        this.overall_form.order_number_generation_rule .push(val)
      }else if(type==4){
        this.purchasing_form.purchase_goods_sort =[]
        this.purchasing_form.purchase_goods_sort .push(val)
      }
    },
    // 保存
    preservation() {
      this.$refs["userListFrom"].validate((valid) => {
        if (valid) {
          // 全局配置
          let overall_form = JSON.parse(JSON.stringify(this.overall_form));
          overall_form.show_member_code = overall_form.show_member_code ? 1 : 0;
          overall_form.order_number_generation_rule =overall_form.order_number_generation_rule .join(",")
          // 订单配置
          let order_form = JSON.parse(JSON.stringify(this.order_form));
          order_form.open_time = this.createTime[0];
          order_form.end_time = this.createTime[1];
          order_form.check_designated_inventory = order_form.check_designated_inventory ? 1 : 0;
          order_form.allow_add_sold_out = order_form.allow_add_sold_out ? 1 : 0;
          order_form.return_audit = order_form.return_audit ? 1 : 0;
          order_form.new_order_voice_switch = order_form.new_order_voice_switch ? 1 : 0;
          order_form.use_recent_remark = order_form.use_recent_remark ? 1 : 0;
          order_form.order_audit = order_form.order_audit ? 1 : 0;
          order_form.new_order_voice_alert=order_form.new_order_voice_alert.join(",")
          order_form.order_goods_sort=order_form.order_goods_sort.join(",")
          // 商品配置
          let commodity_form = JSON.parse(JSON.stringify(this.commodity_form));
          commodity_form.show_sku_code = commodity_form.show_sku_code ? 1 : 0;
          // 库房配置
          let warehouse_form = JSON.parse(JSON.stringify(this.warehouse_form));
          warehouse_form.storage_audit = warehouse_form.storage_audit ? 1 : 0;
          warehouse_form.loss_stock = warehouse_form.loss_stock ? 1 : 0;
          warehouse_form.inventory_sheet_audit = warehouse_form.inventory_sheet_audit ? 1 : 0;
          warehouse_form.reported_spills_autdit = warehouse_form.reported_spills_autdit ? 1 : 0;
          // 商户配置
          let user_form = JSON.parse(JSON.stringify(this.user_form));
          user_form.register_audit = user_form.register_audit ? 1 : 0;
          user_form.register_pay_type = user_form.register_pay_type ? 1 : 0;
          user_form.credit_status = user_form.credit_status ? 1 : 0;
          // 采购配置
          let purchasing_form = JSON.parse(JSON.stringify(this.purchasing_form));
          purchasing_form.purchase_goods_sort =purchasing_form.purchase_goods_sort .join(",")
          purchasing_form.purchase_return_audit = purchasing_form.purchase_return_audit ? 1 : 0;
          purchasing_form.purchase_return_check_inventory = purchasing_form.purchase_return_check_inventory ? 1 : 0;
          purchasing_form.purchase_allow_add_sold_out = purchasing_form.purchase_allow_add_sold_out ? 1 : 0;

          let data = Object.assign(
            {
              sign: Md5(
                objKeySort(Object.assign(apiUrl().name)) + apiUrl().appsecret
              ),
            },
            apiUrl().name,
            this.activeName == 0 ? overall_form : "",
            this.activeName == 1 ? order_form : "",
            this.activeName == 2 ? commodity_form : "",
            this.activeName == 3 ? warehouse_form : "",
            this.activeName == 4 ? user_form : "",
            this.activeName == 5 ? purchasing_form : ""
          );
          setting_company(data).then((res) => {
            if (res.errcode == 0) {
              this.$message({
                message: "保存成功",
                type: "success",
              });
            } else {
              this.$message.error(res.errmsg);
            }
          });
        }
      });
    },
    // 基本信息
    setting_info() {
      let data = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name)) + apiUrl().appsecret
          ),
        },
        apiUrl().name
      );
      setting_info(data).then((res) => {
        if (res.errcode == 0) {
          if (res.data.info) {
            this.overall_form.show_member_code =
              res.data.info.show_member_code == 1 ? true : false;
            if(res.data.info.order_number_generation_rule!=''&&res.data.info.order_number_generation_rule!=null){
              this.overall_form.order_number_generation_rule=[]
              this.overall_form.order_number_generation_rule .push(parseInt(res.data.info.order_number_generation_rule))
            }

            this.order_form.order_audit =
              res.data.info.order_audit == 1 ? true : false;
            if(res.data.info.open_time){
              this.order_form.open_time = res.data.info.open_time;
              this.order_form.end_time = res.data.info.end_time;
              this.createTime=[res.data.info.open_time,res.data.info.end_time];
            }
            this.order_form.check_designated_inventory =
              res.data.info.check_designated_inventory == 1 ? true : false;
            this.order_form.allow_add_sold_out =
              res.data.info.allow_add_sold_out == 1 ? true : false;
            this.order_form.return_audit =
              res.data.info.return_audit == 1 ? true : false;
            this.order_form.use_recent_remark =
              res.data.info.use_recent_remark == 1 ? true : false;
            this.order_form.new_order_voice_switch =
              res.data.info.new_order_voice_switch == 1 ? true : false;
            if(res.data.info.order_goods_sort!=''&&res.data.info.order_goods_sort!=null){
              this.order_form.order_goods_sort=[]
              this.order_form.order_goods_sort .push(parseInt(res.data.info.order_goods_sort))
            }
            if(res.data.info.new_order_voice_alert!=''&&res.data.info.new_order_voice_alert!=null){
              this.order_form.new_order_voice_alert=[]
              this.order_form.new_order_voice_alert .push(res.data.info.new_order_voice_alert)
            }

            this.commodity_form.show_sku_code =
              res.data.info.show_sku_code == 1 ? true : false;

            this.warehouse_form.storage_audit =
              res.data.info.storage_audit == 1 ? true : false;
            this.warehouse_form.loss_stock =
              res.data.info.loss_stock == 1 ? true : false;
            this.warehouse_form.inventory_sheet_audit =
              res.data.info.inventory_sheet_audit == 1 ? true : false;
            this.warehouse_form.reported_spills_autdit =
              res.data.info.reported_spills_autdit == 1 ? true : false;

            this.user_form.register_audit =
              res.data.info.register_audit == 1 ? true : false;
            this.user_form.register_pay_type =
              res.data.info.register_pay_type == 1 ? true : false;
            this.user_form.credit_status =
              res.data.info.credit_status == 1 ? true : false;
            this.user_form.credit = res.data.info.credit;
            this.user_form.credit_notice = res.data.info.credit_notice;
            this.user_form.forbid_order = res.data.info.forbid_order;
            
            this.purchasing_form.purchase_return_audit = res.data.info.purchase_return_audit == 1 ? true : false;
            this.purchasing_form.purchase_return_check_inventory = res.data.info.purchase_return_check_inventory == 1 ? true : false;
            this.purchasing_form.purchase_allow_add_sold_out = res.data.info.purchase_allow_add_sold_out == 1 ? true : false;
          }
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
  },
  created() {
    // 基本信息
    this.setting_info();
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.global_order {
  margin: 0 15px 0 15px;
  .mainua_form {
    .mainua_an {
      /deep/.el-form-item__content {
        margin-left: 0px !important;
      }
      .reset {
        background: $subActive;
        color: $menuText;
        border-color: $subActive;

        &:hover,
        &:focus {
          border-color: $menuActiveText;
          color: $menuActiveText;
        }
      }
    }
  }
}
</style>
